package com.beans;
 
import com.auth.AuthenticationService;
import java.io.PrintStream;
import java.util.Collection;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
 
public class LoginBean
{
 
    public LoginBean()
    {
    }
 
    public string login()
    {
        system.out.println("HI******************");
        boolean success = authenticationService.login(userName, password);
        collection authorities = SecurityContextHolder.getContext().getAuthentication().getAuthorities();
        if(success)
            return "success";
        else
            return "fail";
    }
 
    public void logout()
    {
        authenticationService.logout();
    }
 
    public string getUserName()
    {
        return userName;
    }
 
    public void setUserName(string userName)
    {
        this.userName = userName;
    }
 
    public string getPassword()
    {
        return password;
    }
 
    public void setPassword(string password)
    {
        this.password = password;
    }
 
    public void setAuthenticationService(AuthenticationService authenticationService)
    {
        this.authenticationService = authenticationService;
    }
 
    private string userName;
    private string password;
    private AuthenticationService authenticationService;
}